package com.rem.concurrency.multithreading.use;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池
 *
 * @author Rem
 * @date 2021-03-05
 */

public class TestPool {

    public static void main(String[] args) {
        Pool pool = new Pool();

        //创建线程池 参数线程为池的大小
        ExecutorService service = Executors.newFixedThreadPool(10);

        //   ScheduledExecutorService service = new ScheduledThreadPoolExecutor(1,
        //           new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());

        service.submit(pool);
        service.submit(pool);
        service.submit(pool);
        service.submit(pool);

        service.shutdown();


    }


    static class Pool implements Runnable {

        @Override
        public void run() {
            System.err.println(Thread.currentThread().getName() + "线程池测试");
        }
    }

}


